# It can be seen that the number, 125874, and its double, 251748, 
# contain exactly the same digits, but in a different order.
#
# Find the smallest positive integer, x, 
# such that 2x, 3x, 4x, 5x, and 6x, 
# contain the same digits.
#

#python3

def finddigits(n):
	return sorted(str(n))

def getnewnumber(n):
	count = 1
	while 1:
		count += 1
		if len(str(count))==len(str(count*n)):
			yield count

def verifymagic(i, n):
	lst = [finddigits(i*m) for m in range(1, n+1)]
	boollst = list(map(lambda x: x==lst[0], lst))
	return all(boollst)

def go(n):
	for i in getnewnumber(n):
		if verifymagic(i,n): return i

if __name__ == "__main__":
	assert( finddigits(321) == ['1', '2', '3'] )
	assert( verifymagic(125874, 2) == True  )
	n = go(6)
	print("--",n)
